//mui遮罩显示
var mask = mui.createMask(); //callback为用户点击蒙版时自动执行的回调；
function show() {
    mask.show(); //显示遮罩
}
$(function () {
    //mui初始化
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    Server.getFromCommon('/getMaintenancePdf',{}, function(result){
        if(result.code == 200){
            var values = [];
            var displayValues = [];
            result.data.forEach(function(item, index){
                values.push(item.pdfPath);
                displayValues.push(item.type);
            });
            console.log(result);
            
            $("#picker").picker({
                title: "选择产品类别",
				cols: [{
					textAlign: 'center',
					displayValues: displayValues,
					values: values
				}],
				onClose: function(result) {
                    mask.close();
				}
			});
            $('body').delegate('.picker-button', 'click', function(elem) {
                //跳转预览PDF
                goShowPDF($('.picker-selected').data('picker-value'));
            });
        }
    });
    document.getElementById("confirmBtn").addEventListener('tap', function () {
        mui.confirm('是否拨打4008889880', function (e) {
            if (e.index != 0) {
                var tel = $('<a href="tel:4008889880"></a>');
                tel[0].click();
            }
        })
    });
    // 费用查询弹出框
    $("#serverCost").click(function () {
        $("#searchCost").slideToggle();
        $(".mui-backdrop").css("display", "none");
        // goShowPDF('%E6%81%A9%E4%BB%95%E5%8D%AB%E6%B5%B4%E4%BA%A7%E5%93%81%E7%BB%B4%E4%BF%AE%E6%94%B6%E8%B4%B9%E6%A0%87%E5%87%86.pdf');
        window.location.href= 'img/test.png';
    });
    $("#uploadVideo").click(function () {
        $("#searchCost").slideToggle();
        $(".mui-backdrop").css("display", "none");
    });

    // 选择产品说明书
    $("#city").click(function (elem) {
        var dal = '<div class="_citys"><div class="citys1title">选择配件</div><ul id="_citysheng" class="_citys0"><li class="citySel" id="sheng">选择产品组</li><li id="shi">选择产品</li><li id="xian">选择配件</li></ul><div id="_citys0" class="_citys1"></div><div style="display:none" id="_citys1" class="_citys1"></div><div style="display:none" id="_citys2" class="_citys1"></div></div>';
        Iput.show({ id: this, event: elem, content: dal,width:"470"});
        Server.getFromCommon("/getProduct",{key:"group"}, function(result){
            SelCity(this, elem, result.data);
        });
        console.log(this);
    });
});
/**
 * 查看服务条款
 */
function showService(){
    goShowPDF("%E6%81%A9%E4%BB%95%E5%8D%AB%E6%B5%B4%E4%BA%A7%E5%93%81%E7%BB%B4%E4%BF%AE%E6%94%B6%E8%B4%B9%E6%A0%87%E5%87%86.pdf");
}